package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/09/12 00:17
 **/
public class Day9_6_Num461_HammingDistance {
    class Solution1 {
        public int hammingDistance(int x, int y) {
            int ans = 0;
            while(x != 0 && y != 0){
                if(x % 2 != y % 2) ans++;
                x/=2;
                y/=2;
            }
            return ans;
        }
    }
    class Solution {
        public int hammingDistance(int x, int y) {
            int ret = x ^ y, ans = 0;
            while(ret != 0){
                ans += ret & 1;
                ret >>= 1;
            }
            return ans;
        }
    }
}